<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.3"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>SSDP Help: D:/doxy/PublicAPI/ATEC/RefCounted.h 文件参考</title>
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">SSDP Help<span id="projectnumber">&#160;2.04.01</span>
   </div>
   <div id="projectbrief">仅供测试</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.3 -->
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('../../',false,false,'search.php','搜索');
});
/* @license-end */
</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="../../dir_52a01df1794e5beec01860bdd05aea48.html">PublicAPI</a></li><li class="navelem"><a class="el" href="../../dir_61153f54a0892efe919342a84eb61844.html">ATEC</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">类</a> &#124;
<a href="#define-members">宏定义</a> &#124;
<a href="#func-members">函数</a>  </div>
  <div class="headertitle"><div class="title">RefCounted.h 文件参考</div></div>
</div><!--header-->
<div class="contents">

<p><a href="../../de/ddb/_ref_counted_8h_source.html">浏览源代码.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
类</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../dc/d64/class_ref_counted.html">RefCounted&lt; Base &gt;</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">用于实现引用计数模式的模板类  <a href="../../dc/d64/class_ref_counted.html#details">更多...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
宏定义</h2></td></tr>
<tr class="memitem:a18018cc82b1770e3c844e4c55e3ae07f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/ddb/_ref_counted_8h.html#a18018cc82b1770e3c844e4c55e3ae07f">DEFINE_ATEC_REF_COUNTED_MEMBERS</a></td></tr>
<tr class="separator:a18018cc82b1770e3c844e4c55e3ae07f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a51a6abe9287639469e3ec17f8165d61c"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../de/ddb/_ref_counted_8h.html#a51a6abe9287639469e3ec17f8165d61c">DEFINE_ATEC_REF_COUNTED_MEMBER_INIT</a>&#160;&#160;&#160;m_refCount.store(0);</td></tr>
<tr class="separator:a51a6abe9287639469e3ec17f8165d61c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
函数</h2></td></tr>
<tr class="memitem:a52333269aded4b7d496f31cad4c78540"><td class="memItemLeft" align="right" valign="top"><a id="a52333269aded4b7d496f31cad4c78540" name="a52333269aded4b7d496f31cad4c78540"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>ATEC_TYPEDEFS</b> (IRefCounted)</td></tr>
<tr class="separator:a52333269aded4b7d496f31cad4c78540"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a37b294c0a63261a5ef77bcbe8566b426"><td class="memTemplParams" colspan="2"><a id="a37b294c0a63261a5ef77bcbe8566b426" name="a37b294c0a63261a5ef77bcbe8566b426"></a>
template&lt;class T &gt; </td></tr>
<tr class="memitem:a37b294c0a63261a5ef77bcbe8566b426"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><b>swap</b> (RefCountedPtr&lt; T &gt; &amp;lhs, RefCountedPtr&lt; T &gt; &amp;rhs)</td></tr>
<tr class="separator:a37b294c0a63261a5ef77bcbe8566b426"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa88b68338d90779b993900810711123a"><td class="memTemplParams" colspan="2"><a id="aa88b68338d90779b993900810711123a" name="aa88b68338d90779b993900810711123a"></a>
template&lt;class T &gt; </td></tr>
<tr class="memitem:aa88b68338d90779b993900810711123a"><td class="memTemplItemLeft" align="right" valign="top">T *&#160;</td><td class="memTemplItemRight" valign="bottom"><b>get_pointer</b> (RefCountedPtr&lt; T &gt; const &amp;p)</td></tr>
<tr class="separator:aa88b68338d90779b993900810711123a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af17d13ed069942c1e4be4d0fcd4a54b8"><td class="memTemplParams" colspan="2"><a id="af17d13ed069942c1e4be4d0fcd4a54b8" name="af17d13ed069942c1e4be4d0fcd4a54b8"></a>
template&lt;class T , class U &gt; </td></tr>
<tr class="memitem:af17d13ed069942c1e4be4d0fcd4a54b8"><td class="memTemplItemLeft" align="right" valign="top">RefCountedPtr&lt; T &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><b>static_pointer_cast</b> (RefCountedPtr&lt; U &gt; const &amp;p)</td></tr>
<tr class="separator:af17d13ed069942c1e4be4d0fcd4a54b8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa8d4156cb079381bcf85a047b4c9a9ce"><td class="memTemplParams" colspan="2"><a id="aa8d4156cb079381bcf85a047b4c9a9ce" name="aa8d4156cb079381bcf85a047b4c9a9ce"></a>
template&lt;class T , class U &gt; </td></tr>
<tr class="memitem:aa8d4156cb079381bcf85a047b4c9a9ce"><td class="memTemplItemLeft" align="right" valign="top">RefCountedPtr&lt; T &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><b>const_pointer_cast</b> (RefCountedPtr&lt; U &gt; const &amp;p)</td></tr>
<tr class="separator:aa8d4156cb079381bcf85a047b4c9a9ce"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abd4271bcc2c1a629b25dc2c954f1b37d"><td class="memTemplParams" colspan="2"><a id="abd4271bcc2c1a629b25dc2c954f1b37d" name="abd4271bcc2c1a629b25dc2c954f1b37d"></a>
template&lt;class T , class U &gt; </td></tr>
<tr class="memitem:abd4271bcc2c1a629b25dc2c954f1b37d"><td class="memTemplItemLeft" align="right" valign="top">RefCountedPtr&lt; T &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><b>dynamic_pointer_cast</b> (RefCountedPtr&lt; U &gt; const &amp;p)</td></tr>
<tr class="separator:abd4271bcc2c1a629b25dc2c954f1b37d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><dl class="section author"><dt>作者</dt><dd>SZEWC </dd></dl>
<dl class="section date"><dt>日期</dt><dd>2022/04/28 </dd></dl>
</div><h2 class="groupheader">宏定义说明</h2>
<a id="a51a6abe9287639469e3ec17f8165d61c" name="a51a6abe9287639469e3ec17f8165d61c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a51a6abe9287639469e3ec17f8165d61c">&#9670;&nbsp;</a></span>DEFINE_ATEC_REF_COUNTED_MEMBER_INIT</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define DEFINE_ATEC_REF_COUNTED_MEMBER_INIT&#160;&#160;&#160;m_refCount.store(0);</td>
        </tr>
      </table>
</div><div class="memdoc">
<p >如果在类的定义中使用了DEFINE_ATEC_REF_COUNTED_MEMBERS，需要在构造函数中添加以下宏 </p>

</div>
</div>
<a id="a18018cc82b1770e3c844e4c55e3ae07f" name="a18018cc82b1770e3c844e4c55e3ae07f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a18018cc82b1770e3c844e4c55e3ae07f">&#9670;&nbsp;</a></span>DEFINE_ATEC_REF_COUNTED_MEMBERS</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define DEFINE_ATEC_REF_COUNTED_MEMBERS</td>
        </tr>
      </table>
</div><div class="memdoc">
<b>值:</b><div class="fragment"><div class="line"><span class="keyword">private</span>:\</div>
<div class="line">    mutable AtAtomic&lt;::UInt32&gt; m_refCount;        \</div>
<div class="line">public:\</div>
<div class="line">    void* <span class="keyword">operator</span> <span class="keyword">new</span>(<span class="keywordtype">size_t</span> size) { <span class="keywordflow">return</span> ATECAllocator_allocateRefCounted (size); }  \</div>
<div class="line">    void  <span class="keyword">operator</span> <span class="keyword">delete</span>(<span class="keywordtype">void</span> *rawMem, <span class="keywordtype">size_t</span> size) { ATECAllocator_deleteRefCounted (rawMem, size); }    \</div>
<div class="line">    void* <span class="keyword">operator</span> <span class="keyword">new</span> [](<span class="keywordtype">size_t</span> size) { <span class="keywordflow">return</span> ATECAllocator_allocateArrayRefCounted (size); }  \</div>
<div class="line">    void  <span class="keyword">operator</span> <span class="keyword">delete</span> [] (<span class="keywordtype">void</span> *rawMem, <span class="keywordtype">size_t</span> size) { ATECAllocator_deleteArrayRefCounted (rawMem, size); }   \</div>
<div class="line">public:\</div>
<div class="line">    ::UInt32 AddRef()<span class="keyword"> const </span>{<span class="keywordflow">return</span> ++m_refCount;}\</div>
<div class="line">    ::UInt32 Release() const                      \</div>
<div class="line">        {                                         \</div>
<div class="line">        if (1 &lt; m_refCount--)                     \</div>
<div class="line">            return  m_refCount.load();            \</div>
<div class="line">        delete <span class="keyword">this</span>;                              \</div>
<div class="line">        return  0;                                \</div>
<div class="line">        }</div>
</div><!-- fragment --><p >可以直接使用以下宏来添加IRefCounted的一个实现 必须将DEFINE_ATEC_REF_COUNTED_MEMBER_INIT宏加入到类的构造函数中 通常情况下类应该设置为不可拷贝，否则必须定义拷贝构造函数和赋值构造函数，如RefCounted模板类所示 </p>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3
</small></address>
</body>
</html>
